package com.bdsoft.actions.dicManage.Controller;

import com.bdsoft.actions.AcUrls;
import com.bdsoft.actions.dicManage.Service.DictionaryService;
import com.bdsoft.actions.dicManage.entity.DictDetail;
import com.bdsoft.actions.dicManage.entity.SysDictType;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping(AcUrls.DictionaryManage.dictionaryManageUrl)
@Tag(name = "字典表管理")
public class DictionaryController {
    @Autowired
    private DictionaryService dictionaryService;

    // 字典类型
    @GetMapping("/type/list")
    public List<SysDictType> getDictTypeList(@RequestParam(required = false) String typeCode,
                                             @RequestParam(required = false) String typeName) {
        return dictionaryService.getDictTypeList(typeCode, typeName);
    }
    @PostMapping("/type/add")
    public int addDictType(@RequestBody SysDictType dictType) {
        return dictionaryService.addDictType(dictType);
    }
    @PostMapping("/type/update")
    public int updateDictType(@RequestBody SysDictType dictType) {
        return dictionaryService.updateDictType(dictType);
    }
    @PostMapping("/type/delete")
    public int deleteDictType(@RequestParam String id) {
        return dictionaryService.deleteDictType(id);
    }
    @GetMapping("/type/{id}")
    public SysDictType getDictTypeById(@PathVariable String id) {
        return dictionaryService.getDictTypeById(id);
    }

    // 字典明细
    @GetMapping("/detail/list")
    public List<DictDetail> getDictDetailList(@RequestParam String dictCode) {
        return dictionaryService.getDictDetailList(dictCode);
    }
    @PostMapping("/detail/add")
    public int addDictDetail(@RequestBody DictDetail detail) {
        return dictionaryService.addDictDetail(detail);
    }
    @PostMapping("/detail/update")
    public int updateDictDetail(@RequestBody DictDetail detail) {
        return dictionaryService.updateDictDetail(detail);
    }
    @PostMapping("/detail/delete")
    public int deleteDictDetail(@RequestParam String id) {
        return dictionaryService.deleteDictDetail(id);
    }
    @GetMapping("/detail/{id}")
    public DictDetail getDictDetailById(@PathVariable String id) {
        return dictionaryService.getDictDetailById(id);
    }
}
